﻿import os


oldt = "MyTemplate"

olddir = "Plugin." +oldt + "\\"

files = {"dllmain.cpp",
                oldt+ "Form.cpp",
                oldt + "Form.h",
                "Plugin." + oldt + ".rc",
                "PluginFactory.cpp",
                "PluginFactory.h",
                "Resource.h",
                "stdafx.cpp",
                "stdafx.h",
                "targetver.h",
                "Version.cpp",
                "Plugin." + oldt + ".vcproj"
            }
def main():
    newt = raw_input("please new proj name: \r\n")

    try:
        os.mkdir("Plugin." + newt)
    except:
        pass


    for item in files:
        data = open(olddir + item,"rb").read().replace(oldt,newt)
        nf = ("Plugin." + newt + "\\" + item).replace(oldt,newt)
        open(nf,"wb").write(data)


    os.chdir("Plugin." + newt)
    try:
        os.mkdir("res")
    except:
        pass
    data="""
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
"""

    open("res\\Plugin"+newt+".rc2" , "wb").write(data)




    os.system("pause")

    #pass

if __name__ == '__main__':
    main()